<!--#layout("/common/page.html",{"jsBase":"/js/"}){  -->
<div class="layui-container">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
  <legend>注册</legend>
</fieldset>
<script>
layui.extend({
	 selectN: '{/}/plugins/layui-select-ext/selectN'
});
layui.use(['form','layer','element','selectN'], function(){
	var form = layui.form;
	var selectN = layui.selectN;
	var $ = layui.$;
	
	initSelectArea();
	
	form.on('submit(memberRegForm)', function(){
		var f = this;
		Lib.submitForm("${ctxPath}/member/reg.json",$(f),{},function(data) {
			console.info(data);
			//Common.info("更新成功");
		})
		return false;
    });
	
	function initSelectArea() {
   	 //无限级分类-所有配置
   	    var catIns2 = selectN({
   	      //元素容器【必填】
   	      elem: '#area'
   	      //候选数据【必填】
   	      ,url: "/area/tree.json" 
   	      //设置了长度
   	      ,width:null
   	      ,classNames:"lay-col-md3"
   	      //默认值
   	      ,selected: ["370000000000","370100000000","370114000000","370114002000"] 
   	      ,name:"xxxxxxxxxx"
   	      //为真只取最后一个值
   	      ,last:true       
   	      //空值项提示，可设置为数组['请选择省','请选择市','请选择县']
   	      ,tips: ['请选择省','请选择市','请选择区县']
			  //事件过滤器，lay-filter名 不设置与选择器相同(去#.)
   	      ,filter: ''
		  //input的name 不设置与选择器相同(去#.)
		  //数据分隔符
		  ,delimiter: ','
		  //数据的键名
		  ,field:{idName:'areaCode',titleName:'name',childName:'children'}
		  //表单区分 form.render(type, filter); 为class="layui-form" 所在元素的 lay-filter="" 的值 
		  ,formFilter: null      
   	      ,search:true
   	      ,parentField:"areaCode"
   	      ,parentParamName:"parentAreaCode"
   	      ,selectNames:["provinceCode","cityCode","countryCode"]
   	    }); 
      }  
});
</script>
<form class="layui-form" action="#" lay-filter="memberRegForm" method="post">
  <div class="layui-form-item">
    <label class="layui-form-label">输入手机号</label>
    <div class="layui-input-inline">
      <input type="text" name="phone" id="phone" lay-filter="phone" value="18663765675" lay-verify="required" autocomplete="off" placeholder="请输入手机号" lay-reqText="请输入手机号码" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">昵称</label>
    <div class="layui-input-inline">
      <input type="text" name="userName" lay-verify="required" autocomplete="off" value="格打" placeholder="请输入昵称" lay-reqText="请输入昵称" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">图形码</label>
    <div class="layui-input-inline">
      <input type="text" name="verifyCode" lay-verify="required" id="verifyCode" value="1" autocomplete="off" placeholder="请输入图形码" lay-reqText="请输入图形码" class="layui-input">
    </div>
    <div class="layui-form-mid" style="padding: 0!important;">
      	<img id="img" src="/image" />
      </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">验证码</label>
    <div class="layui-input-inline">
      <input type="text" name="phoneVerifyCode" lay-verify="required" autocomplete="off" value="1" placeholder="请输入手机短信验证码" lay-reqText="请输入手机短信验证码" class="layui-input">
    </div>
    <div class="layui-form-mid" style="padding: 0!important;"> <button type="button" class="layui-btn layui-btn-normal" id="FLY-getvercode">获取验证码</button> </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">密码</label>
    <div class="layui-input-inline">
      <input type="password" name="repassword" value="123123" placeholder="请输入密码" lay-verify="required" autocomplete="off" class="layui-input">
    </div>
  </div>
   <div class="layui-form-item">
    <label class="layui-form-label">确认密码</label>
    <div class="layui-input-inline">
      <input type="password" name="password" value="123123" placeholder="请再次输入密码" lay-verify="required" autocomplete="off" class="layui-input">
    </div>
  </div>
  <!--# if (false) {  -->
  <div class="layui-form-item">
    <label class="layui-form-label">所在地区</label>
    <div class="layui-input-block">
      <layui:areaSelect style='' itemId="area"></layui:areaSelect>
    </div>
  </div>
  <!--# }  -->
  <div class="layui-form-item">
    <div class="layui-input-inline">
      <button type="submit" class="layui-btn" lay-submit="" lay-filter="">立即提交</button>
    </div>
  </div>
</form>
</div>
<script type="text/javascript">
$(function() {
	$("#img").click(function() {
		changeImg();
	});
	 function changeImg() {
	        // var img = document.getElementById("img");
	        $("#img").attr("src","/image?date=" + new Date().getTime());
	    }
	 
	    $("#verifyCode").blur(function () {
	        $.post("/validVeirfyCode", {code:$(this).val()}, function (data) {
	                console.log(data);
	        });
	    });
})
</script>
<!--#}  -->
